Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate ref methods to command #3953

Conversation

YangJonghun
Copy link
Collaborator

@YangJonghun YangJonghun commented Jun 29, 2024

Summary

  • migrate ref methods to command
  • add deprecated warning into getReactTag function
  • remove unused native methods (presentFullscreenPlayer, dismissFullscreenPlayer)
  • wrong type change (drm.getLicense)
    • as-is: () => void
    • to-be: () => string | Promise<string>

Motivation

  • we need to remove findNodeHandle (link)
  • Command doesn't allow return value or callback argument. however save and getCurrentPosition functions return a value. so we have to consider about whether to keep it or drop it.

Changes

Test plan

@@ -2,10 +2,10 @@
* Define Available view type for android
* these values shall match android spec, see ViewType.kt
*/
enum ResizeMode {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

@YangJonghun YangJonghun force-pushed the refactor/migrate-to-command branch from 81ff08d to 57cf079 Compare June 30, 2024 17:02
@KrzysztofMoch
Copy link
Member

I will check if Interop Layer will work with those changes and I am fine to merge this (after @freeboub review)

src/specs/NativeVideoDecoderProperties.ts Outdated Show resolved Hide resolved
src/specs/NativeVideoManagerModule.ts Outdated Show resolved Hide resolved
src/specs/VideoNativeComponent.ts Outdated Show resolved Hide resolved
@YangJonghun YangJonghun requested a review from KrzysztofMoch July 1, 2024 18:50
@KrzysztofMoch
Copy link
Member

@YangJonghun It also seems that we need to do some renaming as setVolume as Command collides with some other setVolume (probably from volume prop) - I suggest to rename setVolume Command to setVolumeCMD. It will be only internal change as we wrap commands in out component

@KrzysztofMoch
Copy link
Member

I am also wandering if we should use TurboModuleRegistry.getEnforcing with old architecture "package" (Turbo modules has it own way to export modules in package - you can find it here). I have check it and we cannot move to it (new TurboModules package way) yet as we need to firstly move view to fabric.

All those changes that I am required from you are from my process of trying to build on New Arch - And I think that we cannot break support for Interop Layer as developers can depend on it. So for now it would be better to back to requireNativeComponent as with those changes I am not able to run app in new arch anymore.
WDYT @YangJonghun @freeboub ?

@YangJonghun
Copy link
Collaborator Author

@KrzysztofMoch
Thanks for comment!
But AFAIK TurboModuleRegistry.getEnforcing works properly on interop layer probably because we didn't set congenConfig.
Also I confirmed that it runs on version 0.74 with new architecture.

@YangJonghun
Copy link
Collaborator Author

@YangJonghun It also seems that we need to do some renaming as setVolume as Command collides with some other setVolume (probably from volume prop) - I suggest to rename setVolume Command to setVolumeCMD. It will be only internal change as we wrap commands in out component

I agree, but I'm a little confused, Am I correct in asking for your suggestion like code below?

    const setVolume = useCallback((volume: number) => {
-      return nativeRef.current && Commands.setVolume(nativeRef.current, volume);
+     return nativeRef.current && Commands.setVolumeCMD(nativeRef.current, volume);
    }, []);

@KrzysztofMoch
Copy link
Member

KrzysztofMoch commented Jul 2, 2024

Also I confirmed that it runs on version 0.74 with new architecture.

👀 In our example ? I have tried to run app with react-native-video (built from this PR) but I wasn't able to do it in basic example nor "clean" RN app (in both I used [email protected])

Am I correct in asking for your suggestion like code below?

Yes this is what I meant

@YangJonghun
Copy link
Collaborator Author

YangJonghun commented Jul 2, 2024

👀 In our example ? I have tried to run app with react-native-video (built from this PR) but I wasn't able to do it in basic example nor "clean" RN app (in both I used [email protected])

No, I tested on my own bare react-native project (created via npx react-native init)
I tried with example! Thanks for let me know

@KrzysztofMoch
Copy link
Member

No, I tested on my own bare react-native project (created via npx react-native init) I tried with example! Thanks to let me know

Strange I also tried to run it on new bare react-native project - it built but there was an error that VideoManager Module is missing "in TurboModule list" (as if it was not detected)

@YangJonghun
Copy link
Collaborator Author

@KrzysztofMoch
I confirmed error you mentioned. Thanks
I'll be restore NativeModules

@YangJonghun
Copy link
Collaborator Author

@KrzysztofMoch
If we need to support interop layer, I think we need to drop this PR.
New arch doesn't support partial migration.🥲
or create new stacked branch and merge it for prepare to support new arch.

@KrzysztofMoch
Copy link
Member

This is something that also thought. I think it would be better to create new arch branch - then step by step migrate it
@freeboub WDYT?

@@ -67,6 +67,6 @@ class VideoDecoderPropertiesModule(reactContext: ReactApplicationContext?) : Rea
companion object {
private val WIDEVINE_UUID = UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L)
private const val SECURITY_LEVEL_PROPERTY = "securityLevel"
private const val REACT_CLASS = "VideoDecoderProperties"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really necessary to change the module name ?

Copy link
Collaborator Author

@YangJonghun YangJonghun Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not required, but I changed it to reduce the chance of duplicates with other library(or core).


RCT_EXPORT_MODULE(RNVDecoderPropertiesModule);

RCT_EXPORT_METHOD(getWidevineLevel : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject) {}
Copy link
Collaborator

@freeboub freeboub Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should al least resolve or reject the Promise... (maybe reject with an error "not implemented") , for these 3 methods

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are meaningless but, acceptable.
I think we should throw an error to notify library contributors.
(we should wrapping decoder properties module on JS side)

@@ -615,15 +611,14 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
drm={_drm}
style={StyleSheet.absoluteFill}
resizeMode={resizeMode}
fullscreen={isFullscreen}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is big, can you confirm the fullscreen property is still available for apps ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, we use internal fullscreen state(for handle present,dismiss fullscreen command) but it was meaningless.
fullscreen prop will be inject with {...rest} and fullscreen commands are work with command.setFullscreen(value).
previous
Rather, the old code was causing different behavior than expected. when user changing fullscreen prop value.

@freeboub
Copy link
Collaborator

freeboub commented Jul 2, 2024

This is something that also thought. I think it would be better to create new arch branch - then step by step migrate it @freeboub WDYT?

Yes It can make sense, but I am really afraid of divergencies... I don't think this PR is too much risky ... but it is still better to merge steps by steps...

@KrzysztofMoch KrzysztofMoch added on-hold PR is on hold for some important reason new architecture PR that contain migration to new architecture labels Jul 4, 2024
@YangJonghun
Copy link
Collaborator Author

@freeboub @KrzysztofMoch
Moved some code fixes to PR #3980

@YangJonghun YangJonghun deleted the refactor/migrate-to-command branch July 12, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new architecture PR that contain migration to new architecture on-hold PR is on hold for some important reason
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants